<?php

/**
 * Test filter form base class.
 *
 * @package    tests
 * @subpackage filter
 * @author     Djul
 */
abstract class BaseTestFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'test_block_id'      => new sfWidgetFormPropelChoice(array('model' => 'TestBlock', 'add_empty' => true)),
      'name'               => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'time'               => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'amount_task_level1' => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'amount_mark_level1' => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'amount_task_level2' => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'amount_mark_level2' => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'amount_task_level3' => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'amount_mark_level3' => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'is_published'       => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
    ));

    $this->setValidators(array(
      'test_block_id'      => new sfValidatorPropelChoice(array('required' => false, 'model' => 'TestBlock', 'column' => 'id')),
      'name'               => new sfValidatorPass(array('required' => false)),
      'time'               => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'amount_task_level1' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'amount_mark_level1' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'amount_task_level2' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'amount_mark_level2' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'amount_task_level3' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'amount_mark_level3' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'is_published'       => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
    ));

    $this->widgetSchema->setNameFormat('test_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Test';
  }

  public function getFields()
  {
    return array(
      'id'                 => 'Number',
      'test_block_id'      => 'ForeignKey',
      'name'               => 'Text',
      'time'               => 'Number',
      'amount_task_level1' => 'Number',
      'amount_mark_level1' => 'Number',
      'amount_task_level2' => 'Number',
      'amount_mark_level2' => 'Number',
      'amount_task_level3' => 'Number',
      'amount_mark_level3' => 'Number',
      'is_published'       => 'Boolean',
    );
  }
}
